/**
 * 
 */
package cn.sundat.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;

import com.alibaba.fastjson.JSON;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import cn.sundat.model.Dict;
import cn.sundat.service.DictService;

/**
 * @author XIN
 *
 */
public class DictAction extends ActionSupport implements ModelDriven<Dict> {

	@Resource(name="dictService")
	private  DictService dictService;
	Dict dict=new Dict();
	@Override
	public Dict getModel() {
		// TODO Auto-generated method stub
		return dict;
	}
	
	public String list() throws IOException {
		List<Dict> findAllDict = dictService.findAllDict();
		String jsonString = JSON.toJSONString(findAllDict);
		ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
		PrintWriter writer = ServletActionContext.getResponse().getWriter();
		writer.print(jsonString);
		writer.flush();
		writer.close();
		return NONE;
	}

}
